﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using hsgsSHXX.DBUtility;//Please add references
using System.Collections.Generic;
namespace hsgsSHXX.DAL
{
	/// <summary>
	/// 数据访问类:wcpcs
	/// </summary>
	public partial class wcpcs
	{
		public wcpcs()
		{}
		#region  Method



		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(hsgsSHXX.Model.wcpcs model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into wcpcs(");
			strSql.Append("BRBH,xm,BLRQ,FBLX,GFNO,XB,BRNL,BRDZ,GMFY,dhhm,SFZH,CSRQ,BRXX,HYZK,YBRYDM,YHLX,YHHM,HKDZ,SZSQ,BLBH,CITY,COUNTY,TOWN,COMMUNITY,ROAD,LANE,NO,ROOM,HEALTH_ID,OCCUPATION,PROVINCE,SLZT,BLZT)");
			strSql.Append(" values (");
			strSql.Append("@BRBH,@xm,@BLRQ,@FBLX,@GFNO,@XB,@BRNL,@BRDZ,@GMFY,@dhhm,@SFZH,@CSRQ,@BRXX,@HYZK,@YBRYDM,@YHLX,@YHHM,@HKDZ,@SZSQ,@BLBH,@CITY,@COUNTY,@TOWN,@COMMUNITY,@ROAD,@LANE,@NO,@ROOM,@HEALTH_ID,@OCCUPATION,@PROVINCE,@SLZT,@BLZT)");
			SqlParameter[] parameters = {
					new SqlParameter("@BRBH", SqlDbType.Float,8),
					new SqlParameter("@xm", SqlDbType.NVarChar,255),
					new SqlParameter("@BLRQ", SqlDbType.DateTime),
					new SqlParameter("@FBLX", SqlDbType.NVarChar,255),
					new SqlParameter("@GFNO", SqlDbType.NVarChar,255),
					new SqlParameter("@XB", SqlDbType.NVarChar,255),
					new SqlParameter("@BRNL", SqlDbType.Float,8),
					new SqlParameter("@BRDZ", SqlDbType.NVarChar,255),
					new SqlParameter("@GMFY", SqlDbType.NVarChar,255),
					new SqlParameter("@dhhm", SqlDbType.NVarChar,255),
					new SqlParameter("@SFZH", SqlDbType.NVarChar,255),
					new SqlParameter("@CSRQ", SqlDbType.DateTime),
					new SqlParameter("@BRXX", SqlDbType.NVarChar,255),
					new SqlParameter("@HYZK", SqlDbType.NVarChar,255),
					new SqlParameter("@YBRYDM", SqlDbType.NVarChar,255),
					new SqlParameter("@YHLX", SqlDbType.NVarChar,255),
					new SqlParameter("@YHHM", SqlDbType.NVarChar,255),
					new SqlParameter("@HKDZ", SqlDbType.NVarChar,255),
					new SqlParameter("@SZSQ", SqlDbType.NVarChar,255),
					new SqlParameter("@BLBH", SqlDbType.NVarChar,255),
					new SqlParameter("@CITY", SqlDbType.NVarChar,255),
					new SqlParameter("@COUNTY", SqlDbType.NVarChar,255),
					new SqlParameter("@TOWN", SqlDbType.NVarChar,255),
					new SqlParameter("@COMMUNITY", SqlDbType.NVarChar,255),
					new SqlParameter("@ROAD", SqlDbType.NVarChar,255),
					new SqlParameter("@LANE", SqlDbType.NVarChar,255),
					new SqlParameter("@NO", SqlDbType.NVarChar,255),
					new SqlParameter("@ROOM", SqlDbType.NVarChar,255),
					new SqlParameter("@HEALTH_ID", SqlDbType.NVarChar,255),
					new SqlParameter("@OCCUPATION", SqlDbType.NVarChar,255),
					new SqlParameter("@PROVINCE", SqlDbType.NVarChar,255),
					new SqlParameter("@SLZT", SqlDbType.NVarChar,255),
					new SqlParameter("@BLZT", SqlDbType.NVarChar,255)};
			parameters[0].Value = model.BRBH;
			parameters[1].Value = model.xm;
			parameters[2].Value = model.BLRQ;
			parameters[3].Value = model.FBLX;
			parameters[4].Value = model.GFNO;
			parameters[5].Value = model.XB;
			parameters[6].Value = model.BRNL;
			parameters[7].Value = model.BRDZ;
			parameters[8].Value = model.GMFY;
			parameters[9].Value = model.dhhm;
			parameters[10].Value = model.SFZH;
			parameters[11].Value = model.CSRQ;
			parameters[12].Value = model.BRXX;
			parameters[13].Value = model.HYZK;
			parameters[14].Value = model.YBRYDM;
			parameters[15].Value = model.YHLX;
			parameters[16].Value = model.YHHM;
			parameters[17].Value = model.HKDZ;
			parameters[18].Value = model.SZSQ;
			parameters[19].Value = model.BLBH;
			parameters[20].Value = model.CITY;
			parameters[21].Value = model.COUNTY;
			parameters[22].Value = model.TOWN;
			parameters[23].Value = model.COMMUNITY;
			parameters[24].Value = model.ROAD;
			parameters[25].Value = model.LANE;
			parameters[26].Value = model.NO;
			parameters[27].Value = model.ROOM;
			parameters[28].Value = model.HEALTH_ID;
			parameters[29].Value = model.OCCUPATION;
			parameters[30].Value = model.PROVINCE;
			parameters[31].Value = model.SLZT;
			parameters[32].Value = model.BLZT;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(hsgsSHXX.Model.wcpcs model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update wcpcs set ");
			strSql.Append("BRBH=@BRBH,");
			strSql.Append("xm=@xm,");
			strSql.Append("BLRQ=@BLRQ,");
			strSql.Append("FBLX=@FBLX,");
			strSql.Append("GFNO=@GFNO,");
			strSql.Append("XB=@XB,");
			strSql.Append("BRNL=@BRNL,");
			strSql.Append("BRDZ=@BRDZ,");
			strSql.Append("GMFY=@GMFY,");
			strSql.Append("dhhm=@dhhm,");
			strSql.Append("SFZH=@SFZH,");
			strSql.Append("CSRQ=@CSRQ,");
			strSql.Append("BRXX=@BRXX,");
			strSql.Append("HYZK=@HYZK,");
			strSql.Append("YBRYDM=@YBRYDM,");
			strSql.Append("YHLX=@YHLX,");
			strSql.Append("YHHM=@YHHM,");
			strSql.Append("HKDZ=@HKDZ,");
			strSql.Append("SZSQ=@SZSQ,");
			strSql.Append("BLBH=@BLBH,");
			strSql.Append("CITY=@CITY,");
			strSql.Append("COUNTY=@COUNTY,");
			strSql.Append("TOWN=@TOWN,");
			strSql.Append("COMMUNITY=@COMMUNITY,");
			strSql.Append("ROAD=@ROAD,");
			strSql.Append("LANE=@LANE,");
			strSql.Append("NO=@NO,");
			strSql.Append("ROOM=@ROOM,");
			strSql.Append("HEALTH_ID=@HEALTH_ID,");
			strSql.Append("OCCUPATION=@OCCUPATION,");
			strSql.Append("PROVINCE=@PROVINCE,");
			strSql.Append("SLZT=@SLZT,");
			strSql.Append("BLZT=@BLZT");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
					new SqlParameter("@BRBH", SqlDbType.Float,8),
					new SqlParameter("@xm", SqlDbType.NVarChar,255),
					new SqlParameter("@BLRQ", SqlDbType.DateTime),
					new SqlParameter("@FBLX", SqlDbType.NVarChar,255),
					new SqlParameter("@GFNO", SqlDbType.NVarChar,255),
					new SqlParameter("@XB", SqlDbType.NVarChar,255),
					new SqlParameter("@BRNL", SqlDbType.Float,8),
					new SqlParameter("@BRDZ", SqlDbType.NVarChar,255),
					new SqlParameter("@GMFY", SqlDbType.NVarChar,255),
					new SqlParameter("@dhhm", SqlDbType.NVarChar,255),
					new SqlParameter("@SFZH", SqlDbType.NVarChar,255),
					new SqlParameter("@CSRQ", SqlDbType.DateTime),
					new SqlParameter("@BRXX", SqlDbType.NVarChar,255),
					new SqlParameter("@HYZK", SqlDbType.NVarChar,255),
					new SqlParameter("@YBRYDM", SqlDbType.NVarChar,255),
					new SqlParameter("@YHLX", SqlDbType.NVarChar,255),
					new SqlParameter("@YHHM", SqlDbType.NVarChar,255),
					new SqlParameter("@HKDZ", SqlDbType.NVarChar,255),
					new SqlParameter("@SZSQ", SqlDbType.NVarChar,255),
					new SqlParameter("@BLBH", SqlDbType.NVarChar,255),
					new SqlParameter("@CITY", SqlDbType.NVarChar,255),
					new SqlParameter("@COUNTY", SqlDbType.NVarChar,255),
					new SqlParameter("@TOWN", SqlDbType.NVarChar,255),
					new SqlParameter("@COMMUNITY", SqlDbType.NVarChar,255),
					new SqlParameter("@ROAD", SqlDbType.NVarChar,255),
					new SqlParameter("@LANE", SqlDbType.NVarChar,255),
					new SqlParameter("@NO", SqlDbType.NVarChar,255),
					new SqlParameter("@ROOM", SqlDbType.NVarChar,255),
					new SqlParameter("@HEALTH_ID", SqlDbType.NVarChar,255),
					new SqlParameter("@OCCUPATION", SqlDbType.NVarChar,255),
					new SqlParameter("@PROVINCE", SqlDbType.NVarChar,255),
					new SqlParameter("@SLZT", SqlDbType.NVarChar,255),
					new SqlParameter("@BLZT", SqlDbType.NVarChar,255)};
			parameters[0].Value = model.BRBH;
			parameters[1].Value = model.xm;
			parameters[2].Value = model.BLRQ;
			parameters[3].Value = model.FBLX;
			parameters[4].Value = model.GFNO;
			parameters[5].Value = model.XB;
			parameters[6].Value = model.BRNL;
			parameters[7].Value = model.BRDZ;
			parameters[8].Value = model.GMFY;
			parameters[9].Value = model.dhhm;
			parameters[10].Value = model.SFZH;
			parameters[11].Value = model.CSRQ;
			parameters[12].Value = model.BRXX;
			parameters[13].Value = model.HYZK;
			parameters[14].Value = model.YBRYDM;
			parameters[15].Value = model.YHLX;
			parameters[16].Value = model.YHHM;
			parameters[17].Value = model.HKDZ;
			parameters[18].Value = model.SZSQ;
			parameters[19].Value = model.BLBH;
			parameters[20].Value = model.CITY;
			parameters[21].Value = model.COUNTY;
			parameters[22].Value = model.TOWN;
			parameters[23].Value = model.COMMUNITY;
			parameters[24].Value = model.ROAD;
			parameters[25].Value = model.LANE;
			parameters[26].Value = model.NO;
			parameters[27].Value = model.ROOM;
			parameters[28].Value = model.HEALTH_ID;
			parameters[29].Value = model.OCCUPATION;
			parameters[30].Value = model.PROVINCE;
			parameters[31].Value = model.SLZT;
			parameters[32].Value = model.BLZT;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from wcpcs ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
};

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public hsgsSHXX.Model.wcpcs GetModel()
		{
			//该表无主键信息，请自定义主键/条件字段
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 BRBH,xm,BLRQ,FBLX,GFNO,XB,BRNL,BRDZ,GMFY,dhhm,SFZH,CSRQ,BRXX,HYZK,YBRYDM,YHLX,YHHM,HKDZ,SZSQ,BLBH,CITY,COUNTY,TOWN,COMMUNITY,ROAD,LANE,NO,ROOM,HEALTH_ID,OCCUPATION,PROVINCE,SLZT,BLZT from wcpcs ");
			strSql.Append(" where ");
			SqlParameter[] parameters = {
};

			hsgsSHXX.Model.wcpcs model=new hsgsSHXX.Model.wcpcs();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["BRBH"]!=null && ds.Tables[0].Rows[0]["BRBH"].ToString()!="")
				{
					model.BRBH=decimal.Parse(ds.Tables[0].Rows[0]["BRBH"].ToString());
				}
				if(ds.Tables[0].Rows[0]["xm"]!=null && ds.Tables[0].Rows[0]["xm"].ToString()!="")
				{
					model.xm=ds.Tables[0].Rows[0]["xm"].ToString();
				}
				if(ds.Tables[0].Rows[0]["BLRQ"]!=null && ds.Tables[0].Rows[0]["BLRQ"].ToString()!="")
				{
					model.BLRQ=DateTime.Parse(ds.Tables[0].Rows[0]["BLRQ"].ToString());
				}
				if(ds.Tables[0].Rows[0]["FBLX"]!=null && ds.Tables[0].Rows[0]["FBLX"].ToString()!="")
				{
					model.FBLX=ds.Tables[0].Rows[0]["FBLX"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GFNO"]!=null && ds.Tables[0].Rows[0]["GFNO"].ToString()!="")
				{
					model.GFNO=ds.Tables[0].Rows[0]["GFNO"].ToString();
				}
				if(ds.Tables[0].Rows[0]["XB"]!=null && ds.Tables[0].Rows[0]["XB"].ToString()!="")
				{
					model.XB=ds.Tables[0].Rows[0]["XB"].ToString();
				}
				if(ds.Tables[0].Rows[0]["BRNL"]!=null && ds.Tables[0].Rows[0]["BRNL"].ToString()!="")
				{
					model.BRNL=decimal.Parse(ds.Tables[0].Rows[0]["BRNL"].ToString());
				}
				if(ds.Tables[0].Rows[0]["BRDZ"]!=null && ds.Tables[0].Rows[0]["BRDZ"].ToString()!="")
				{
					model.BRDZ=ds.Tables[0].Rows[0]["BRDZ"].ToString();
				}
				if(ds.Tables[0].Rows[0]["GMFY"]!=null && ds.Tables[0].Rows[0]["GMFY"].ToString()!="")
				{
					model.GMFY=ds.Tables[0].Rows[0]["GMFY"].ToString();
				}
				if(ds.Tables[0].Rows[0]["dhhm"]!=null && ds.Tables[0].Rows[0]["dhhm"].ToString()!="")
				{
					model.dhhm=ds.Tables[0].Rows[0]["dhhm"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SFZH"]!=null && ds.Tables[0].Rows[0]["SFZH"].ToString()!="")
				{
					model.SFZH=ds.Tables[0].Rows[0]["SFZH"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CSRQ"]!=null && ds.Tables[0].Rows[0]["CSRQ"].ToString()!="")
				{
					model.CSRQ=DateTime.Parse(ds.Tables[0].Rows[0]["CSRQ"].ToString());
				}
				if(ds.Tables[0].Rows[0]["BRXX"]!=null && ds.Tables[0].Rows[0]["BRXX"].ToString()!="")
				{
					model.BRXX=ds.Tables[0].Rows[0]["BRXX"].ToString();
				}
				if(ds.Tables[0].Rows[0]["HYZK"]!=null && ds.Tables[0].Rows[0]["HYZK"].ToString()!="")
				{
					model.HYZK=ds.Tables[0].Rows[0]["HYZK"].ToString();
				}
				if(ds.Tables[0].Rows[0]["YBRYDM"]!=null && ds.Tables[0].Rows[0]["YBRYDM"].ToString()!="")
				{
					model.YBRYDM=ds.Tables[0].Rows[0]["YBRYDM"].ToString();
				}
				if(ds.Tables[0].Rows[0]["YHLX"]!=null && ds.Tables[0].Rows[0]["YHLX"].ToString()!="")
				{
					model.YHLX=ds.Tables[0].Rows[0]["YHLX"].ToString();
				}
				if(ds.Tables[0].Rows[0]["YHHM"]!=null && ds.Tables[0].Rows[0]["YHHM"].ToString()!="")
				{
					model.YHHM=ds.Tables[0].Rows[0]["YHHM"].ToString();
				}
				if(ds.Tables[0].Rows[0]["HKDZ"]!=null && ds.Tables[0].Rows[0]["HKDZ"].ToString()!="")
				{
					model.HKDZ=ds.Tables[0].Rows[0]["HKDZ"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SZSQ"]!=null && ds.Tables[0].Rows[0]["SZSQ"].ToString()!="")
				{
					model.SZSQ=ds.Tables[0].Rows[0]["SZSQ"].ToString();
				}
				if(ds.Tables[0].Rows[0]["BLBH"]!=null && ds.Tables[0].Rows[0]["BLBH"].ToString()!="")
				{
					model.BLBH=ds.Tables[0].Rows[0]["BLBH"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CITY"]!=null && ds.Tables[0].Rows[0]["CITY"].ToString()!="")
				{
					model.CITY=ds.Tables[0].Rows[0]["CITY"].ToString();
				}
				if(ds.Tables[0].Rows[0]["COUNTY"]!=null && ds.Tables[0].Rows[0]["COUNTY"].ToString()!="")
				{
					model.COUNTY=ds.Tables[0].Rows[0]["COUNTY"].ToString();
				}
				if(ds.Tables[0].Rows[0]["TOWN"]!=null && ds.Tables[0].Rows[0]["TOWN"].ToString()!="")
				{
					model.TOWN=ds.Tables[0].Rows[0]["TOWN"].ToString();
				}
				if(ds.Tables[0].Rows[0]["COMMUNITY"]!=null && ds.Tables[0].Rows[0]["COMMUNITY"].ToString()!="")
				{
					model.COMMUNITY=ds.Tables[0].Rows[0]["COMMUNITY"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ROAD"]!=null && ds.Tables[0].Rows[0]["ROAD"].ToString()!="")
				{
					model.ROAD=ds.Tables[0].Rows[0]["ROAD"].ToString();
				}
				if(ds.Tables[0].Rows[0]["LANE"]!=null && ds.Tables[0].Rows[0]["LANE"].ToString()!="")
				{
					model.LANE=ds.Tables[0].Rows[0]["LANE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["NO"]!=null && ds.Tables[0].Rows[0]["NO"].ToString()!="")
				{
					model.NO=ds.Tables[0].Rows[0]["NO"].ToString();
				}
				if(ds.Tables[0].Rows[0]["ROOM"]!=null && ds.Tables[0].Rows[0]["ROOM"].ToString()!="")
				{
					model.ROOM=ds.Tables[0].Rows[0]["ROOM"].ToString();
				}
				if(ds.Tables[0].Rows[0]["HEALTH_ID"]!=null && ds.Tables[0].Rows[0]["HEALTH_ID"].ToString()!="")
				{
					model.HEALTH_ID=ds.Tables[0].Rows[0]["HEALTH_ID"].ToString();
				}
				if(ds.Tables[0].Rows[0]["OCCUPATION"]!=null && ds.Tables[0].Rows[0]["OCCUPATION"].ToString()!="")
				{
					model.OCCUPATION=ds.Tables[0].Rows[0]["OCCUPATION"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PROVINCE"]!=null && ds.Tables[0].Rows[0]["PROVINCE"].ToString()!="")
				{
					model.PROVINCE=ds.Tables[0].Rows[0]["PROVINCE"].ToString();
				}
				if(ds.Tables[0].Rows[0]["SLZT"]!=null && ds.Tables[0].Rows[0]["SLZT"].ToString()!="")
				{
					model.SLZT=ds.Tables[0].Rows[0]["SLZT"].ToString();
				}
				if(ds.Tables[0].Rows[0]["BLZT"]!=null && ds.Tables[0].Rows[0]["BLZT"].ToString()!="")
				{
					model.BLZT=ds.Tables[0].Rows[0]["BLZT"].ToString();
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select BRBH,xm,BLRQ,FBLX,GFNO,XB,BRNL,BRDZ,GMFY,dhhm,SFZH,CSRQ,BRXX,HYZK,YBRYDM,YHLX,YHHM,HKDZ,SZSQ,BLBH,CITY,COUNTY,TOWN,COMMUNITY,ROAD,LANE,NO,ROOM,HEALTH_ID,OCCUPATION,PROVINCE,SLZT,BLZT ");
			strSql.Append(" FROM wcpcs ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" BRBH,xm,BLRQ,FBLX,GFNO,XB,BRNL,BRDZ,GMFY,dhhm,SFZH,CSRQ,BRXX,HYZK,YBRYDM,YHLX,YHHM,HKDZ,SZSQ,BLBH,CITY,COUNTY,TOWN,COMMUNITY,ROAD,LANE,NO,ROOM,HEALTH_ID,OCCUPATION,PROVINCE,SLZT,BLZT ");
			strSql.Append(" FROM wcpcs ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM wcpcs ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T. desc");
			}
			strSql.Append(")AS Row, T.*  from wcpcs T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "wcpcs";
			parameters[1].Value = "";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method
        public List<hsgsSHXX.Model.wcpcs> DataTableToList(DataTable dt)
        {
            List<hsgsSHXX.Model.wcpcs> modelList = new List<hsgsSHXX.Model.wcpcs>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                hsgsSHXX.Model.wcpcs model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new hsgsSHXX.Model.wcpcs();
                    //if (dt.Rows[n]["BRBH"] != null && dt.Rows[n]["BRBH"].ToString() != "")
                    //{
                    //    model.BRBH = decimal.Parse(dt.Rows[n]["BRBH"].ToString());
                    //}
                    if (dt.Rows[n]["xm"] != null && dt.Rows[n]["xm"].ToString() != "")
                    {
                        model.xm = dt.Rows[n]["xm"].ToString();
                    }
                    if (dt.Rows[n]["BLRQ"] != null && dt.Rows[n]["BLRQ"].ToString() != "")
                    {
                        model.BLRQ = DateTime.Parse(dt.Rows[n]["BLRQ"].ToString());
                    }
                    //if (dt.Rows[n]["FBLX"] != null && dt.Rows[n]["FBLX"].ToString() != "")
                    //{
                    //    model.FBLX = dt.Rows[n]["FBLX"].ToString();
                    //}
                    //if (dt.Rows[n]["GFNO"] != null && dt.Rows[n]["GFNO"].ToString() != "")
                    //{
                    //    model.GFNO = dt.Rows[n]["GFNO"].ToString();
                    //}
                    if (dt.Rows[n]["XB"] != null && dt.Rows[n]["XB"].ToString() != "")
                    {
                        model.XB = dt.Rows[n]["XB"].ToString();
                    }
                    if (dt.Rows[n]["BRNL"] != null && dt.Rows[n]["BRNL"].ToString() != "")
                    {
                        model.BRNL = decimal.Parse(dt.Rows[n]["BRNL"].ToString());
                    }
                    if (dt.Rows[n]["BRDZ"] != null && dt.Rows[n]["BRDZ"].ToString() != "")
                    {
                        model.BRDZ = dt.Rows[n]["BRDZ"].ToString();
                    }
                    //if (dt.Rows[n]["GMFY"] != null && dt.Rows[n]["GMFY"].ToString() != "")
                    //{
                    //    model.GMFY = dt.Rows[n]["GMFY"].ToString();
                    //}
                    if (dt.Rows[n]["dhhm"] != null && dt.Rows[n]["dhhm"].ToString() != "")
                    {
                        model.dhhm = dt.Rows[n]["dhhm"].ToString();
                    }
                    if (dt.Rows[n]["SFZH"] != null && dt.Rows[n]["SFZH"].ToString() != "")
                    {
                        model.SFZH = dt.Rows[n]["SFZH"].ToString();
                    }
                    if (dt.Rows[n]["CSRQ"] != null && dt.Rows[n]["CSRQ"].ToString() != "")
                    {
                        model.CSRQ = DateTime.Parse(dt.Rows[n]["CSRQ"].ToString());
                    }
                    //if (dt.Rows[n]["BRXX"] != null && dt.Rows[n]["BRXX"].ToString() != "")
                    //{
                    //    model.BRXX = dt.Rows[n]["BRXX"].ToString();
                    //}
                    //if (dt.Rows[n]["HYZK"] != null && dt.Rows[n]["HYZK"].ToString() != "")
                    //{
                    //    model.HYZK = dt.Rows[n]["HYZK"].ToString();
                    //}
                    //if (dt.Rows[n]["YBRYDM"] != null && dt.Rows[n]["YBRYDM"].ToString() != "")
                    //{
                    //    model.YBRYDM = dt.Rows[n]["YBRYDM"].ToString();
                    //}
                    //if (dt.Rows[n]["YHLX"] != null && dt.Rows[n]["YHLX"].ToString() != "")
                    //{
                    //    model.YHLX = dt.Rows[n]["YHLX"].ToString();
                    //}
                    //if (dt.Rows[n]["YHHM"] != null && dt.Rows[n]["YHHM"].ToString() != "")
                    //{
                    //    model.YHHM = dt.Rows[n]["YHHM"].ToString();
                    //}
                    //if (dt.Rows[n]["HKDZ"] != null && dt.Rows[n]["HKDZ"].ToString() != "")
                    //{
                    //    model.HKDZ = dt.Rows[n]["HKDZ"].ToString();
                    //}
                    //if (dt.Rows[n]["SZSQ"] != null && dt.Rows[n]["SZSQ"].ToString() != "")
                    //{
                    //    model.SZSQ = dt.Rows[n]["SZSQ"].ToString();
                    //}
                    //if (dt.Rows[n]["BLBH"] != null && dt.Rows[n]["BLBH"].ToString() != "")
                    //{
                    //    model.BLBH = dt.Rows[n]["BLBH"].ToString();
                    //}
                    //if (dt.Rows[n]["CITY"] != null && dt.Rows[n]["CITY"].ToString() != "")
                    //{
                    //    model.CITY = dt.Rows[n]["CITY"].ToString();
                    //}
                    //if (dt.Rows[n]["COUNTY"] != null && dt.Rows[n]["COUNTY"].ToString() != "")
                    //{
                    //    model.COUNTY = dt.Rows[n]["COUNTY"].ToString();
                    //}
                    //if (dt.Rows[n]["TOWN"] != null && dt.Rows[n]["TOWN"].ToString() != "")
                    //{
                    //    model.TOWN = dt.Rows[n]["TOWN"].ToString();
                    //}
                    //if (dt.Rows[n]["COMMUNITY"] != null && dt.Rows[n]["COMMUNITY"].ToString() != "")
                    //{
                    //    model.COMMUNITY = dt.Rows[n]["COMMUNITY"].ToString();
                    //}
                    //if (dt.Rows[n]["ROAD"] != null && dt.Rows[n]["ROAD"].ToString() != "")
                    //{
                    //    model.ROAD = dt.Rows[n]["ROAD"].ToString();
                    //}
                    //if (dt.Rows[n]["LANE"] != null && dt.Rows[n]["LANE"].ToString() != "")
                    //{
                    //    model.LANE = dt.Rows[n]["LANE"].ToString();
                    //}
                    //if (dt.Rows[n]["NO"] != null && dt.Rows[n]["NO"].ToString() != "")
                    //{
                    //    model.NO = dt.Rows[n]["NO"].ToString();
                    //}
                    //if (dt.Rows[n]["ROOM"] != null && dt.Rows[n]["ROOM"].ToString() != "")
                    //{
                    //    model.ROOM = dt.Rows[n]["ROOM"].ToString();
                    //}
                    //if (dt.Rows[n]["HEALTH_ID"] != null && dt.Rows[n]["HEALTH_ID"].ToString() != "")
                    //{
                    //    model.HEALTH_ID = dt.Rows[n]["HEALTH_ID"].ToString();
                    //}
                    //if (dt.Rows[n]["OCCUPATION"] != null && dt.Rows[n]["OCCUPATION"].ToString() != "")
                    //{
                    //    model.OCCUPATION = dt.Rows[n]["OCCUPATION"].ToString();
                    //}
                    //if (dt.Rows[n]["PROVINCE"] != null && dt.Rows[n]["PROVINCE"].ToString() != "")
                    //{
                    //    model.PROVINCE = dt.Rows[n]["PROVINCE"].ToString();
                    //}
                    //if (dt.Rows[n]["SLZT"] != null && dt.Rows[n]["SLZT"].ToString() != "")
                    //{
                    //    model.SLZT = dt.Rows[n]["SLZT"].ToString();
                    //}
                    //if (dt.Rows[n]["BLZT"] != null && dt.Rows[n]["BLZT"].ToString() != "")
                    //{
                    //    model.BLZT = dt.Rows[n]["BLZT"].ToString();
                    //}
                    modelList.Add(model);
                }
            }
            return modelList;
        }
        public List<Model.wcpcs> GetFondListByPage(int pageSize, int pageIndex, string strWhere, string fOrderFiled, out int total)
        {
            if (fOrderFiled == "")
            {
                fOrderFiled = "BRBH desc";
            }
            SqlParameter[] parameters = {  
                    new SqlParameter("@tableName", SqlDbType.VarChar, 50),  
                    new SqlParameter("@fields", SqlDbType.VarChar, 2000),  
                    new SqlParameter("@orderField", SqlDbType.VarChar, 500),  
                    new SqlParameter("@sqlWhere", SqlDbType.VarChar,2000),  
                    new SqlParameter("@pageSize", SqlDbType.Int),  
                    new SqlParameter("@pageIndex", SqlDbType.Int),  
                    new SqlParameter("@TotalPage", SqlDbType.Int),
                    new SqlParameter("@TotalRecordCount", SqlDbType.Int) 
                    };

            parameters[0].Value = "wcpcs";
            parameters[1].Value = "xm,blrq,xb,brnl,brdz,dhhm,sfzh,csrq";
            parameters[2].Value = fOrderFiled;
            parameters[3].Value = strWhere;
            parameters[4].Value = pageSize;
            parameters[5].Value = pageIndex;
            parameters[6].Direction = ParameterDirection.Output;
            parameters[7].Direction = ParameterDirection.Output;
            DataSet ds = DbHelperSQL.RunProcedure("up_GetRecordByPage", parameters, "ds", 60 * 30);
            total = int.Parse(parameters[7].Value.ToString());
            return DataTableToList(ds.Tables[0]);

        }
	}
}

